﻿using System;
using System.Web;
using System.Web.Mvc;
using Ornament.MemberShip;
using Ornament.Web.Mvc;

namespace Ornament.Web.ModelBinder
{
    public class UserBinder : BaseModelBinder
    {
        protected override object RequestId(HttpRequestBase request)
        {
            string id = request["Id"];
            if (id == null)
                return null;
            return new Guid(id);
        }


        protected override object CreateNewObject(ControllerContext controllerContext,
                                                  ModelBindingContext bindingContext, Type modelType)
        {
            string loginId = controllerContext.RequestContext.HttpContext.Request["LoginId"];
            return new User(loginId);
        }
    }
}